package cn.tedu.kcircle.comment.front.adapter.rpc;


import cn.tedu.kcircle.comment.front.api.rpc.CommentFrontRpcApi;
import cn.tedu.kcircle.comment.front.api.rpc.po.CommentListItemPO;
import cn.tedu.kcircle.comment.front.repository.persist.CommentRepository;
import cn.tedu.kcircle.common.dto.ResourceDTO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
public class CommentFrontRpcApiImpl implements CommentFrontRpcApi {
    private CommentRepository commentRepository;
    private CommentConverter converter;
    @Override
    public int deleteByResource(ResourceDTO resourceDTO) {
        return commentRepository.deleteByResource(resourceDTO);
    }

    @Override
    public List<CommentListItemPO> listByAuthorId(Long id) {
        return converter.bo2POList(commentRepository.listByAuthorId(id));
    }
}
